package com.ymttest.database.sqlwapper;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.mapping.GodProductActivityStockMapper;
import com.ymttest.database.model.GodProductActivityStock;
import com.ymttest.database.model.couponsendsubtask;
import com.ymttest.database.model.couponsendtaskfailrecord;
import com.ymttest.utils.EnvSetup;

public class GodProductActivityStockWapper {
	SqlManager manager;

    public GodProductActivityStockWapper() {
    	manager = new SqlManager("intpro");
	}
    
    /**
     * 根据主键查询
     * @param ProductActivityStockID
     * @return
     */
    public GodProductActivityStock selectByProductActivityStockID(String ProductActivityStockID)  {
    	Map map=new HashMap<String,Object>();
    	map.put("sProductActivityStockID", ProductActivityStockID);
        List<GodProductActivityStock> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.GodProductActivityStockMapper.selectByPrimaryKey",
                        map);
        if(result.size()>0)
        {
        	return result.get(0);
        }
        return null;
    }
    
    /**
     *    根据商品id查询
     * @param ProductId
     * @return
     */
    public GodProductActivityStock selectByProductId(String productId)  {
    	Map map=new HashMap<String,Object>();
    	map.put("sProductID", productId);
        List<GodProductActivityStock> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.GodProductActivityStockMapper.selectByProductId",
                        map);
        if(result.size()>0)
        {
        	return result.get(0);
        }
        return null;
    }
    
    
    /**
     *    根据商品id查询
     * @param ProductId
     * @return
     */
    public GodProductActivityStock selectByProductIdAndCatalogId(String ProductId,String CatalogId)  {
    	Map map=new HashMap<String,Object>();
    	map.put("sProductID", ProductId);
    	map.put("sCatalogID", CatalogId);
        List<GodProductActivityStock> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.GodProductActivityStockMapper.selectByProductIdAndCatalogId",
                        map);
        if(result.size()>0)
        {
        	return result.get(0);
        }
        return null;
    }
    
    /**
     *    根据商品id和活动id，查询商品在活动中的id
     * @param ProductId
     * @return
     */
    public int selectProductInActivityId(String productId,int activityId)  {
    	Map map=new HashMap<String,Object>();
    	map.put("sProductID", productId);
    	map.put("iActivityID", activityId);
        List<GodProductActivityStock> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.GodProductActivityStockMapper.selectProductInActivityId",
                        map);
        if(result.size()>0)
        {
        	return result.get(0).getiProductInActivityId();
        }
        return 0;
    }
    
  



    public static void main(String[] args) {
    	GodProductActivityStock selectByProductId = new GodProductActivityStockWapper().selectByProductId("PROD244dc4c3-e2b8-4ee9-ae20-6f28e0c1");
    	System.out.println(selectByProductId);
    	System.out.println(selectByProductId==null);
    }
}
